
<h1>Permission example</h1>

<p>This is an example how to set permission using model.</p>

<p>Simple set permission</p>

<pre class="brush: php">
// Load model
$this->load->model('dx_auth/permissions', 'permissions');

// Set permission 'edit' permission to TRUE for role_id = 1.
$this->permissions->set_permission_value(1, 'edit', TRUE);
</pre>

<p>Set permission value at once.</p>

<pre class="brush: php">
// Load model
$this->load->model('dx_auth/permissions', 'permissions');

// Get role_id = 1 permission data first. 
// So the previously set permission array key won't be overwritten with new array with key $key only, 
// when calling set_permission_data later.
$permission_data = $this->permissions->get_permission_data(1);

// Set value in permission data array
$permission_data['edit'] = TRUE;
$permission_data['delete'] = FALSE;

// Set permission data for role_id = 1
$this->permissions->set_permission_data(1, $permission_data);
</pre>

<p>This is an example how to get the permission using DX Auth, after user already logged in.</p>

<pre class="brush: php">
if ($this->dx_auth->get_permission_value('edit') != NULL AND $this->dx_auth->get_permission_value('edit'))
{
	echo 'Editing is allowed in your role';
}
else
{
	echo 'Editing is not allowed in your role';
}
</pre>

<p>You can see more of the example, in <strong>controllers/backend.php</strong> in uri_permissions and custom_permissions function.</p>

<? $this->docs->color_syntax(); ?>